import { CoolController, BaseController } from '@cool-midway/core';
import { GoodsPromoTcEntity } from '../../entity/promo_tc';
import { GoodsPromoTcService } from '../../service/promo_tc.service';
import { Body, Inject, Post } from '@midwayjs/core';

/**
 * 促销套餐管理
 */
@CoolController({
  api: ['page', 'info'],
  entity: GoodsPromoTcEntity,
  service: GoodsPromoTcService,
  pageQueryOp: {
    keyWordLikeFields: ['a.goodsId'],
    fieldEq: ['a.status', 'a.billNo'],
    addOrderBy: {
      createTime: 'desc',
    },
  },
})
export class AdminGoodsPromoTcController extends BaseController {
  @Inject()
  goodsPromoTcService: GoodsPromoTcService;

  @Post('/getByBillNo')
  async getByBillNo(@Body() params: { billNo: string }) {
    return this.ok(await this.goodsPromoTcService.getByBillNo(params.billNo));
  }

  @Post('/getByGoodsId')
  async getByGoodsId(@Body() params: { goodsId: string }) {
    return this.ok(await this.goodsPromoTcService.getByGoodsId(params.goodsId));
  }

  @Post('/getAllActiveDetails')
  async getAllActiveDetails() {
    return this.ok(await this.goodsPromoTcService.getAllActiveDetails());
  }

  @Post('/calculateComboPrice')
  async calculateComboPrice(@Body() params: { billNo: string }) {
    return this.ok(await this.goodsPromoTcService.calculateComboPrice(params.billNo));
  }
} 